from django.shortcuts import render
from django.http import HttpResponse
import json
from . import models
# Create your views here.

def login(request):
    # json loads dumps
    #json。loads 来将数据变为json对象
   
    user = json.loads(request.body)
    if user['password'] == '123':
        ret = {'code':1000,'msg':'登录成功', 'user':user['username']}
    else:
        ret = {'code':1001, 'msg':'登录失败，密码错误'}
    return HttpResponse( json.dumps(ret) )